package phone.stubs;

import phone.beans.MessageBean;

import com.google.gson.Gson;

public class PhoneStubMessages {
	public static void main(String[] args){			
		// JSON for user who is inside the LobbyServer receiving refresh updates
		String test = "{\"type\":9,\"gameServers\":[{\"name\":\"Test\",\"numPlayers\":2,\"hasPassword\":true}]}";
		System.out.println(test);
		Gson gson = new Gson();
        MessageBean bean = gson.fromJson(test, MessageBean.class);
        System.out.println("Phone received message type " + bean.getType());
        System.out.println("Name // Num Players // Password?");
        for(int i = 0; i < bean.getGameServers().length; i ++) {
        	System.out.println(bean.getGameServers()[i].getName() + " // " + bean.getGameServers()[i].getNumPlayers() + "	// " + bean.getGameServers()[i].isHasPassword());
        }
        
		String test1 = "{\"type\":2}";
		System.out.println("\n" + test1);
		Gson gson1 = new Gson();
        MessageBean bean1 = gson1.fromJson(test1, MessageBean.class);
        System.out.println("Phone received message type " + bean1.getType());

		// JSON for user who is inside a GameServer and receiving updates about the state of the game
		String test2 = "{\"type\":4,\"gameServer\":{\"name\":\"Test\",\"numPlayers\":2,\"gameModel\":{\"scoreboard\":{\"timeLeft\":{\"hour\":{\"currCount\":0},\"minute\":{\"currCount\":5},\"second\":{\"currCount\":60}},\"teamAScore\":0,\"teamBScore\":0,\"maxScore\":1,\"state\":0},\"ball\":{\"position\":{\"x\":400.0,\"y\":200.0}},\"playerList\":{\"Player (1)\":{\"position\":{\"x\":75.0,\"y\":244.0},\"name\":\"Player (1)\",\"team\":0},\"Player\":{\"position\":{\"x\":75.0,\"y\":200.0},\"name\":\"Player\",\"team\":0}}},\"hasPassword\":true}}";
		System.out.println("\n" + test2);
		Gson gson2 = new Gson();
		MessageBean bean2 = gson2.fromJson(test2, MessageBean.class);
        System.out.println("Phone received message type " + bean2.getType());
		System.out.println("Name of Game: " + bean2.getGameServer().getName() + " // Number of Players: " + bean2.getGameServer().getNumPlayers());
		System.out.println("Red Score " + bean2.getGameServer().getGameModel().getScoreboard().getTeamAScore() + " // Blue Score: " + bean2.getGameServer().getGameModel().getScoreboard().getTeamBScore());
	
	}
}
